import { componentObj, currentComponent, currentTheme } from './data';

export const getMaxIndex = (): number => {
  if (currentTheme.value.image.length === 0) {
    return 1;
  }

  let maxZ = currentTheme.value.image[0].z;

  for (const box of currentTheme.value.image) {
    if (box.z > maxZ) {
      maxZ = box.z;
    }
  }

  return maxZ + 1;
};
export const deleteComponent = () => {
  currentTheme.value.image = currentTheme.value.image.filter(e => {
    return e.id !== currentComponent.value?.id;
  });
  currentComponent.value = {
    ...componentObj,
  };
};
